# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgname=gst-libav
pkgver=1.14.4
pkgrel=1
pkgdesc="GStreamer Multimedia Framework ffmpeg Plugin"
url="https://gstreamer.freedesktop.org/"
arch=(x86_64)
license=(GPL)
depends=(gst-plugins-base-libs bzip2)
makedepends=(python gtk-doc autoconf-archive git yasm)
provides=("gst-ffmpeg=$pkgver-$pkgrel")
_commit=1c21e61bc18cdbf94ee6510f837a7ddc65c8831e  # tags/1.14.4^0
source=("git+https://anongit.freedesktop.org/git/gstreamer/gst-libav#commit=$_commit"
        "gst-common::git+https://anongit.freedesktop.org/git/gstreamer/common"
        "git+https://git.videolan.org/git/ffmpeg" "git://git.libav.org/gas-preprocessor")
sha256sums=('SKIP'
            'SKIP'
            'SKIP'
            'SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgname

  git submodule init
  git config --local submodule.common.url "$srcdir/gst-common"
  git config --local submodule.gst-libs/ext/libav.url "$srcdir/ffmpeg"
  git config --local submodule.gst-libs/ext/gas-preprocessor.url "$srcdir/gas-preprocessor"
  git submodule update

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --with-package-name="GStreamer ffmpeg Plugin (Arch Linux)" \
    --with-package-origin="https://www.archlinux.org/" \
    --without-system-libav \
    --with-libav-extra-configure="--enable-runtime-cpudetect" \
    --enable-experimental \
    --enable-gtk-doc \
    --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  make check
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
}
